﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class admin_product_dimnew : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void newProductGridView_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("cancelNew"))
        {
            int productId = Convert.ToInt32(e.CommandArgument);
            DB db = new DB();
            db.cancelNew(productId);
            Response.Redirect("dimnew.aspx");
        }
    }
    protected void allProductGridView_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("dimNew"))
        {
            int productId = Convert.ToInt32(e.CommandArgument);
            DB db = new DB();
            db.dimNew(productId);
            Response.Redirect("dimnew.aspx");
        }
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        allProductGridView.DataSourceID = null;
        //当选择的类别改变了，就要改变全部产品中的值
        int cid = Convert.ToInt32(DropDownList1.SelectedValue);
        DB db = new DB();
        if (cid == -1)
        {
            allProductGridView.DataSource = db.getNotNewProducts();
            allProductGridView.DataBind();
        }
        else
        {
            allProductGridView.DataSource = db.getProductsByCategory(cid);
            allProductGridView.DataBind();
        }

    }
}
